Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var e = require("../@babel/runtime/helpers/classCallCheck"), n = require("../@babel/runtime/helpers/createClass"), t = function() {
    function t() {
        e(this, t), this.isLoading = !1;
    }
    return n(t, null, [ {
        key: "toast",
        value: function(e, n) {
            var t = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "none", o = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 2e3;
            wx.showToast({
                title: e,
                icon: t,
                mask: !0,
                duration: o
            }), n && setTimeout(function() {
                n();
            }, o);
        }
    }, {
        key: "error",
        value: function(e, n) {
            wx.showToast({
                title: e,
                mask: !0,
                duration: 500
            }), n && setTimeout(function() {
                n();
            }, 500);
        }
    }, {
        key: "loading",
        value: function() {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "加载中";
            t.isLoading || (t.isLoading = !0, wx.showLoading({
                title: e,
                mask: !0
            }));
        }
    }, {
        key: "loaded",
        value: function() {
            t.isLoading && (t.isLoading = !1, wx.hideLoading());
        }
    }, {
        key: "action",
        value: function(e) {
            return new Promise(function(n, t) {
                wx.showActionSheet({
                    itemList: e,
                    success: function(t) {
                        var o = {
                            index: t.tapIndex,
                            text: e[t.tapIndex]
                        };
                        n(o);
                    },
                    fail: function(e) {
                        t(e.errMsg);
                    }
                });
            });
        }
    }, {
        key: "actionWithFunc",
        value: function(e) {
            for (var n = arguments.length, t = new Array(n > 1 ? n - 1 : 0), o = 1; o < n; o++) t[o - 1] = arguments[o];
            wx.showActionSheet({
                itemList: e,
                success: function(e) {
                    var n = e.tapIndex;
                    n >= 0 && n < t.length && t[n]();
                }
            });
        }
    }, {
        key: "alert",
        value: function(e) {
            var n = e.text, t = e.payload, o = void 0 === t ? {} : t, i = e.title, c = void 0 === i ? "" : i, a = e.confirmText, s = void 0 === a ? "确定" : a;
            return new Promise(function(e, t) {
                wx.showModal({
                    title: c,
                    content: n,
                    showCancel: !1,
                    confirmText: s,
                    confirmColor: "#0252DA",
                    success: function(n) {
                        n.confirm ? e(o) : n.cancel && t(o);
                    },
                    fail: function() {}
                });
            });
        }
    }, {
        key: "confirm",
        value: function(e) {
            var n = e.text, t = e.payload, o = void 0 === t ? {} : t, i = e.title, c = void 0 === i ? "" : i, a = e.confirmText, s = void 0 === a ? "确定" : a, r = e.cancelText, u = void 0 === r ? "取消" : r;
            return new Promise(function(e, t) {
                wx.showModal({
                    title: c,
                    content: n,
                    showCancel: !0,
                    cancelText: u,
                    confirmText: s,
                    confirmColor: "#0252DA",
                    success: function(n) {
                        n.confirm ? e(o) : n.cancel && t(o);
                    },
                    fail: function() {}
                });
            });
        }
    }, {
        key: "modal",
        value: function(e) {
            var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "温馨提示";
            return new Promise(function(t, o) {
                wx.showModal({
                    title: n,
                    content: e,
                    showCancel: !1,
                    confirmColor: "#0252DA",
                    success: function(e) {
                        t(e);
                    },
                    fail: function(e) {
                        o(e);
                    }
                });
            });
        }
    }, {
        key: "share",
        value: function(e, n, o) {
            return {
                title: e,
                path: n,
                desc: o,
                success: function() {
                    t.toast("分享成功");
                }
            };
        }
    } ]), t;
}();

exports.default = t, t.isLoading = !1;